﻿using SelfManagement.Web.App_Start;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using UEditor;

namespace SelfManagement.Web
{
    public class RouteConfig
    {

        /// <summary>
        /// 默认路由
        /// </summary>
        public const string Default = "Default";

        /// <summary>
        /// 错误页面路由
        /// </summary>
        public const string Error = "Error";

        /// <summary>
        /// 信息页面路由
        /// </summary>
        public const string Message = "Message";

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //错误页面路由
            routes.MapRoute(
                name: RouteConfig.Error,
                url: "errors/{code}.html",
                defaults: new { controller = "Errors", action = "Error", id = UrlParameter.Optional },
                namespaces: new string[] { "Fishcoo.Web.Controllers" }
            );

            //错误页面路由
            routes.MapRoute(
                name: RouteConfig.Message,
                url: "messages/{code}.html",
                defaults: new { controller = "Messages", action = "Message", id = UrlParameter.Optional },
                namespaces: new string[] { "Fishcoo.Web.Controllers" }
            );

            //百度编辑器路由
            routes.Add(new UEditorRoute("/UEditor/Api", UEditorConfigure.Common));

            //默认路由
            routes.MapRoute(
                name: RouteConfig.Default,
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                namespaces: new string[] { "Fishcoo.Web.Controllers" }
            );
        }
    }
}
